<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        /*  function myPromise(url) {
             return new Promise((resolve, reject) => {
                 $.ajax({
                     url: url,
                     success: res => {
                         resolve(res)
                     },
                     fail: err => {
                         reject(err)
                     }
                 })
             })
         }
 
         myPromise('../data/1.json')
             .then(res => {
                 console.log(res)
                 return res.count >= 0 ? myPromise('../data/2.json') : ''
             })
             .then(res => {
                 console.log(res)
                 return res.count >= 1 ? myPromise('../data/3.json') : ''
             })
             .then(res => console.log(res)) */


        /*  function myPromise(url) {
             return new Promise((resolve, reject) => {
                 $.ajax({
                     url: url,
                     success: res => resolve(res)
                 })
             })
         }
 
         myPromise('../data/1.json')
             .then(res => {
                 console.log(res)
                 return res.count >= 0 ? myPromise('../data/2.json') : ''
             })
             .then(res => {
                 console.log(res)
                 return res.count >= 1 ? myPromise('../data/3.json') : ''
             })
             .then(res => console.log(res)) */

        function myPromise(url) {
            return new Promise((resolve, reject) => {
                $.ajax({
                    url: url,
                    success: res => resolve(res)
                })
            })
        }

        myPromise('../data/1.json')
            .then(res => {
                console.log(res)
                return res.count >= 0 ? myPromise('../data/2.json') : ''
            })
            .then(res => {
                console.log(res)
                return res.count >= 1 ? myPromise('../data/3.json') : ''
            })
            .then(res => console.log(res))
    </script>
</body>

</html>